#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
#include "beep.h"
#include "key.h"

//GEC STM32F407开发板 
//按键输入实验-库函数版本 
int main(void)
{ 
    u8 key;           //保存键值
	delay_init(168);  //初始化延时函数
	LED_Init();				//初始化LED端口 
	BEEP_Init();      //初始化蜂鸣器端口
	KEY_Init();       //初始化与按键连接的硬件接口
	LED0=0;
	LED1=0;
	LED2=0;				  	//先点亮红灯
	while(1)
	{
		key=KEY_Scan(0);		//得到键值
	    if(key)
		{						   
			switch(key)
			{				 
				case KEY0_PRES:	//控制蜂鸣器
					BEEP=!BEEP;
					break;
				case KEY1_PRES:	//控制LED0翻转
					LED0=!LED0;
					break;
				case KEY2_PRES:	//控制LED1翻转	 
					LED1=!LED1;
					break;
				case KEY3_PRES:	//控制LED2翻转 
					LED2=!LED2;
					break;
			}
		}
        else delay_ms(10);
	}
}

#include"sys.h"
#include"usart.h"
#include"delay.h"
#include"beep.h"
#include"lcd.h"
#include"key.h"

int main(){
    u8 key;
    delay_init(168);
    LCD_Init();
    BEEP_Init();
    KEY_Init();
    LED0 = 0;
    LED1 = 0;
    LED2 = 0;
    while(1){
        key = KEY_Scan(0);
        if(key){
            switch(key){
                case KEY0_PRES:
                    BEEP = !BEEP;
                    break;
                case KEY1_PRES:
                    LED0 = !LED0;
                    break;
                case KEY2_PRES:
                    LED1 = !LED1;
                    break;
                case KEY3_PRES:
                    LED2 = !LED2;
                    break;
            }
        }
        else delay_ms(10);
    }
}
